﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.SalesManagement;
using MediatR;
using Sell.Api.Write.Application.Command.PhrasesCommand;
using Sell.Services.Phrases;

namespace Sell.Api.Write.Application.CommandHandlers.PhrasesCommandHandlers
{
    public class PhrasesUpdateCommandHandlers : IRequestHandler<PhrasesUpdateCommand, ApiResult<int>>
    {
        public IMapper Mapper { get; }
        public IPhrasesServices services { get; }
        public PhrasesUpdateCommandHandlers(IPhrasesServices _services, IMapper _Mapper)
        {
            Mapper = _Mapper;
            services = _services;
        }
        /// <summary>
        /// 销售合同修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ApiResult<int>> Handle(PhrasesUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = Mapper.Map<Phrase>(request);
            return await services.UpdatePhrase(list);
        }
    }
}
